package com.zyms.controller.api;

import com.zyms.controller.baseController.WebBaseController;
import com.zyms.module.result.ReturnCode;
import com.zyms.module.user.User;
import com.zyms.myRunTime.MyRunTimeExcption;
import com.zyms.module.result.ResultObj;
import com.zyms.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by Baggio on 2018-1-24.
 */
@Controller
public class IndexController  extends WebBaseController {

    @Autowired
    UserService userService;
    @RequestMapping(value="/api/index",method = RequestMethod.POST)
    @ResponseBody
    public ResultObj apiIndex(HttpServletRequest request, HttpServletResponse response, Long activityId) {
        logger.info("=============================index==============================================>>>>>>"+activityId);
        ResultObj resultObj=new ResultObj();
        try {
            User user=new User();
            userService.login(user);
            resultObj.setData("aaaaaaaaaaaaaaaaaaaaaaaaaa");
        } catch (MyRunTimeExcption myRunTimeExcption) {
            resultObj.setCode(myRunTimeExcption.getErroCode());
            resultObj.setMsg(myRunTimeExcption.getMessage());
            logger.info(myRunTimeExcption.getMessage());
            myRunTimeExcption.printStackTrace();
        }catch (Exception e) {
            resultObj.setCode(ReturnCode.SYSTEM_ERRO.getCode());
            resultObj.setMsg(e.getMessage());
            logger.info("Exception============>>>>"+e.getMessage());
         //   e.printStackTrace();
        }
        return resultObj;
    }
}
